﻿namespace TwiterApi.Tests
{
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using TwitterApi;

    [TestClass]
    public class AuthenticationTests
    {
        private const string ConsumerKey = "iSzCAq21MlWLyzebmZOyUg";
        private const string ConsumerSecret = "TgURTF38WpW7JkQReKcxjoaA7LrflTdacYAB6ulfw";

        [TestMethod]
        public void ShouldReturnRequestToken()
        {
            var requestToken = Proxy.GetRequestToken(ConsumerKey, ConsumerSecret);

            Assert.IsNotNull(requestToken.Token);
            Assert.IsNotNull(requestToken.Secret);
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException))]
        public void ShouldGetRequestTokenThrowExceptionIfConsumerKeySecretIsInvalid()
        {
            var requestToken = Proxy.GetRequestToken("invalid-key", "invalid-secret");
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException))]
        public void ShouldGetAccessTokenThrowExceptionIfRequestTokenIsInvalid()
        {
            var invalidToken = new OAuthToken()
            {
                Token = "invalid-token",
                Secret = "invalid-secret"
            };

            var requestToken = Proxy.GetAccessToken(ConsumerKey, ConsumerSecret, invalidToken, "invalid-request-verifier");
        }
    }
}